#!/bin/bash

phrase="descriptive statistics for duty to vote"
lines_to_extract=105

awk -v p="$phrase" -v n="$lines_to_extract" '
    index($0, p) && !found { found=1; start=NR }
    found && NR >= start && NR < start+n { print }
' log.txt > besip_sample_stats.txt


phrase="average times"
lines_to_extract=23

awk -v p="$phrase" -v n="$lines_to_extract" '
    index($0, p) && !found { found=1; start=NR }
    found && NR >= start && NR < start+n { print }
' log.txt > besip_waves.txt


phrase="estimates and significance"
lines_to_extract=210

awk -v p="$phrase" -v n="$lines_to_extract" '
    index($0, p) && !found { found=1; start=NR }
    found && NR >= start && NR < start+n { print }
' log.txt > besip_coefficients.txt


phrase="variance decomposition for each dependent variable"
lines_to_extract=41

awk -v p="$phrase" -v n="$lines_to_extract" '
    index($0, p) && !found { found=1; start=NR }
    found && NR >= start && NR < start+n { print }
' log.txt > besip_variance.txt

